//
//  MessageCommonTableViewCell.m
//  BGM
//
//  Created by liuqin on 2018/11/27.
//  Copyright © 2018年 com.alirtc.demo. All rights reserved.
//

#import "MessageCommonTableViewCell.h"
#import "Common.h"
#import "UIImageView+WebCache.h"
@interface  MessageCommonTableViewCell()




@end


@implementation MessageCommonTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self != nil) {
        self.iconimageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 8, 45, 45)];
        [self addSubview:self.iconimageView];
        
        self.messageLabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 0, 200, 61)];
        self.messageLabel.textColor = bgmmainColor;
        self.messageLabel.font = [UIFont systemFontOfSize:18];
        [self addSubview:self.messageLabel];
        
 
        
        UILabel *lable1 = [[UILabel alloc]initWithFrame:CGRectMake(15, 60, SCREENW, 0.5)];
        lable1.backgroundColor = [UIColor grayColor];
        lable1.alpha = 0.3;
        [self addSubview:lable1];
        
        
        self.seleBtn = [[UIButton alloc]initWithFrame:CGRectMake(SCREENW-50, 15, 30, 30)];
  
        [self.seleBtn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];

        [self addSubview:self.seleBtn];
        self.seleBtn.hidden = YES;
        
    }
    return self;
}


- (void)setGroupNumbersInfo:(NIMTeam *)member sele:(BOOL)isSele{
 
    [self.seleBtn setImage:[UIImage imageNamed:@"titleNormal"] forState:UIControlStateNormal];
    [self.seleBtn setImage:[UIImage imageNamed:@"tittleSele"] forState:UIControlStateSelected];
    [self.iconimageView setImage:[UIImage imageNamed:@"groupHead"]];
    self.messageLabel.text = member.teamName;
    self.seleBtn.selected = isSele;
    
}
- (void)setUserInfo:(NIMUser *)user sele:(BOOL)isSele{
    
    NIMUserInfo *info = user.userInfo;
    [self.iconimageView sd_setImageWithURL:[NSURL URLWithString:info.avatarUrl] placeholderImage:[UIImage imageNamed:@"headImage"]];
    self.messageLabel.text = info.nickName;
    [self.seleBtn setTitle:@"答谢" forState:UIControlStateNormal];
    self.seleBtn.frame = CGRectMake(SCREENW-80, 15, 50, 30);
    self.seleBtn.layer.cornerRadius = 8;
    self.seleBtn.layer.masksToBounds = YES;
    self.seleBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [self.seleBtn setTitleColor:bgmgrayColor forState:UIControlStateNormal];
    self.seleBtn.selected = isSele;
    if (self.seleBtn.selected) {
        self.seleBtn.backgroundColor = bgmyelloeColor;
    }else{
        self.seleBtn.backgroundColor = bgmColor(224, 224, 224);

    }
}
- (void)clickBtn:(UIButton *)btn{
    if (self.isThankUser) {
        if (self.seleBtn.selected) {
            [self.cellDelegate gotoThankUser:(int)self.seleBtn.tag];
        }
       
    }else{
        btn.selected = !btn.selected;
        [self.cellDelegate seleRow:(int)btn.tag isSele:btn.selected];
    }
    

    
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
